﻿using PermissionManager.Model;
using PermissionsManager.BLL;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PermissionManager.BLL
{
    public class AdminUserAPIService:BaseService<AdminUser>
    {
        /// <summary>
        /// 登录校验
        /// </summary>
        /// <param name="moduleName"></param>
        /// <param name="username"></param>
        /// <param name="pwd"></param>
        /// <returns></returns>
        public AdminUser ValidateLogin(string moduleName, string username, string pwd)
        {
            using (var db = new PermissionManagerEntities())
            {
                var result = from a in db.Module
                             join b in db.ModuleUser
                             on a.Id equals b.ModuleId
                             join c in db.AdminUser
                             on b.AdminUserId equals c.Id
                             where a.Name == moduleName && c.Name == username && c.Password == pwd
                             select c;

                return result.ToList().FirstOrDefault();
            }
        }
    }
}
